package com.atguigu.yygh.oss.controller;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.oss.service.UploadService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.UUID;

/**
 * @Author luoyin
 * @Date 13:12 2022/10/5
 **/
@RestController
@RequestMapping("/user/oss")
//@CrossOrigin
public class UploadController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("/upload")
    public R upload(MultipartFile file){
        String url = uploadService.upload(file);
        return R.ok().data("url",url);
    }
}
